package FactoryMethod;
import java.util.ArrayList;
import java.util.List;
public class demo {
    /**
     * @param args
     */
    public static void main(String[] args) {
   
        Fruit fruit1 = Factory.getFruitInstanceByType("苹果");
        Fruit fruit2 = Factory.getFruitInstanceByType("橘子");
        //  Fruit fruit3 = Factory.getFruitInstanceByType(null);
        //  Fruit fruit3 = Factory.getFruitInstanceByType("null");
        try {
             Fruit fruit3 = Factory.getFruitInstanceByType(null);
             fruit3.showname();
         } 
         catch (NullPointerException e) {
             System.out.println("Error: " + e.getMessage());
        }
        System.out.println(fruit1.showname());
        System.out.println(fruit2.showname());
        // System.out.println(fruit3.showname());



    }
}
